package ynu.edu.common.domain.stats;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StatsData<T> {
    private Long total;
    private T detail;
    private String status;  // SUCCESS, UPDATING, ERROR
    private String message;

    // 成功状态
    public static <T> StatsData<T> success(T detail, Long total) {
        return new StatsData<>(total, detail, "SUCCESS", null);
    }

    // 更新中状态
    public static <T> StatsData<T> updating() {
        return new StatsData<>(null, null, "UPDATING", "数据更新中");
    }

    // 错误状态
    public static <T> StatsData<T> error(String message) {
        return new StatsData<>(null, null, "ERROR", message);
    }
}